﻿
using System ;

using MskEdit.Dxf.Model ;


namespace MskEdit.Dxf.Backend
{
    internal class DxfVariableReader
    {

#region Internal operations    
                
        internal static DxfVariable TryRead( string[] allLines, ref int lineNo, DxfVariable fallbackVariable ) {
        
            int internalLineNo = lineNo ;
            
            string variableName = DxfLineReader.TryRead( "9", allLines, ref internalLineNo, null ) ;
            if ( variableName == null )
                return fallbackVariable ;

            object variableValue = DxfValueReader.TryRead( allLines, ref internalLineNo, null ) ;
            if ( variableValue == null ) 
                return fallbackVariable ;
            
            lineNo = internalLineNo ;
            
            return new DxfVariable( variableName, variableValue ) ;
        }

#endregion

    }
}
